<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title>奖品库详情</title>
    <#include "/view/admin/head.html"/>
    
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
    <script type="text/javascript" src="${base}/jstool/bootstrap-select/js/bootstrap-select.min.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-select/lang/defaults-zh_CN.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-select/css/bootstrap-select.min.css" />    

    <style type="text/css">
        .list-path{
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;

        }
        .table-class{
            width:80%;
            text-align: center;
            border:1px solid #afd9ee;
            margin:0 auto;
            margin-top: 50px;
        }
        table th{
            width:20%;
            background-color: #d9edf7;
            text-align: right;
        }
        table td{
            width:20%;
            text-align: left;
        }
        .go-back{
            float:right;
            margin-right: 30px;

        }
    </style>

<script type="text/javascript">
function firstFileImg() {
		//input
		var docObj = document.getElementById("firstFile");
		//img
		var imgObjPreview = document.getElementById("firstImg");
		//div
		var divs = document.getElementById("localImag");
		if (docObj.files && docObj.files[0]) {
			//火狐下，直接设img属性
			imgObjPreview.style.width = '242px';
			imgObjPreview.style.height = '170px';
			//imgObjPreview.src = docObj.files[0].getAsDataURL();
			//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
			imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
		} else {
			//IE下，使用滤镜
			docObj.select();
			var imgSrc = document.selection.createRange().text;
			var localImagId = document.getElementById("localImag");
			//必须设置初始大小
			localImagId.style.width = "242px";
			localImagId.style.height = "170px";
			//图片异常的捕捉，防止用户修改后缀来伪造图片
			try {
				localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
				localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
			} catch(e) {
				alert("您上传的图片格式不正确，请重新选择!");
				return false;
			}
			
			imgObjPreview.style.display = 'none';
			
			document.selection.empty();
		}
		return true;
	}  

function secondFileImg() {
	//input
	var docObj = document.getElementById("secondFile");
	//img
	var imgObjPreview = document.getElementById("secondImg");
	//div
	var divs = document.getElementById("localImag");
	if (docObj.files && docObj.files[0]) {
		//火狐下，直接设img属性
		imgObjPreview.style.width = '242px';
		imgObjPreview.style.height = '170px';
		//imgObjPreview.src = docObj.files[0].getAsDataURL();
		//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		//IE下，使用滤镜
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		//必须设置初始大小
		localImagId.style.width = "242px";
		localImagId.style.height = "170px";
		//图片异常的捕捉，防止用户修改后缀来伪造图片
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch(e) {
			alert("您上传的图片格式不正确，请重新选择!");
			return false;
		}
		
		imgObjPreview.style.display = 'none';
		
		document.selection.empty();
	}
	return true;
}  

function thirdFileImg() {
	//input
	var docObj = document.getElementById("thirdFile");
	//img
	var imgObjPreview = document.getElementById("thirdImg");
	//div
	var divs = document.getElementById("localImag");
	if (docObj.files && docObj.files[0]) {
		//火狐下，直接设img属性
		imgObjPreview.style.width = '242px';
		imgObjPreview.style.height = '170px';
		//imgObjPreview.src = docObj.files[0].getAsDataURL();
		//火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
		imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);
	} else {
		//IE下，使用滤镜
		docObj.select();
		var imgSrc = document.selection.createRange().text;
		var localImagId = document.getElementById("localImag");
		//必须设置初始大小
		localImagId.style.width = "242px";
		localImagId.style.height = "170px";
		//图片异常的捕捉，防止用户修改后缀来伪造图片
		try {
			localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
			localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
		} catch(e) {
			alert("您上传的图片格式不正确，请重新选择!");
			return false;
		}
		
		imgObjPreview.style.display = 'none';
		
		document.selection.empty();
	}
	return true;
}  


</script>    
    
</head>
<body>

<div class="list-path" > <span style="margin-left: 50px;"><span class="glyphicon glyphicon-home"></span> 奖品库详情</span></div>
    <div style="float:right;margin-right: 40px;"><a class="btn btn-info" href="${base}/awardstock/czjawardstockList.do">返回</a></div>
</div>


<div class="table-class">       
      <#if  message?? &&  message =="1" >
        <div class="alert alert-error" style="background-color: write;color: green;">           
           <font size="5"><strong>发布成功</strong></font>
        </div>
     </#if>
      <#if  message?? &&  message =="0" >
        <div class="alert alert-error" style="background-color: write;color: red;">           
           <font size="5"><strong>取消发布</strong></font>
        </div>
     </#if>
      <#if  message?? &&  message =="2" >
        <div class="alert alert-error" style="background-color: write;color: green;">           
           <font size="5"><strong>保存成功</strong></font>
        </div>
     </#if>     
      
    <table class="table table-bordered">
        <thead>

        </thead>
        <tbody>
          <form  action="${base}/awardstock/czjawardstockSave.do?awardstockId=${czjawardstock.awardstockId!}" method="post" enctype="multipart/form-data"   id="myform" >
              <tr>
                <th>奖品名称：</th>
                <td>
                ${czjawardstock.thingName!}                               
                </td>
                <th>奖品类型：</th>
                <td>
                     <#if czjawardstock.awardType?? && czjawardstock.awardType==1>  活动优惠劵  </#if> 
                     <#if czjawardstock.awardType?? && czjawardstock.awardType==2>  商品优惠券  </#if> 
                     <#if czjawardstock.awardType?? && czjawardstock.awardType==3>  实物商品  </#if> 
                     <#if czjawardstock.awardType?? && czjawardstock.awardType==4>  红包  </#if> 
                     <#if czjawardstock.awardType?? && czjawardstock.awardType==5>  活动优惠名额  </#if> 
                     <#if czjawardstock.awardType?? && czjawardstock.awardType==6>  谢谢参与  </#if>                     
                </td>                
              </tr>                             
              <tr>
                <th>截止使用日期：</th>
                <td>
                   <#if czjawardstock.validDate??> ${czjawardstock.validDate?string('yyyy-MM-dd')}</#if>                                 
                </td>                
                <th>谢谢参与数量：</th>
                <td> 
                  ${czjawardstock.countnum!}                                                                     
                </td>
              </tr>               
              <tr>
                <th>谢谢参与描述：</th>
                <td>
                ${czjawardstock.content!}
                 </td>
                <th></th>
                <td>   
                </td>
              </tr>                                                                                           
              <tr>
                <th >预览我的奖品中图片：</th>
                <td ><img src="${base}${czjawardstock.prizePath!}" height="140px;" width="140px" id="secondImg"></td>
                <th ></th>
                <td ></td>                
              </tr>                
              

              

     </form>   
              
        </tbody>
    </table>

</div>

<script type="text/javascript">


function discountShopSel(){
	  var discountShop = $("#discountShop").val();
	
	    $.ajax({  
	        type : "post",  //提交方式  
	        url : "czjthingId.do",//路径  
	        async: false,
	        data : "discountShop="+discountShop,//数据，这里使用的是Json格式进行传输      
	        dataType: "json",
	        success : function(result) {//返回数据根据结果进行相应的处理  
	       console.log(result.result);	
	        var result = result.result;
	        console.log(result);
            
	        
	        $("#ext3").find("option").remove();
	        
	        $("#ext3").append("<option value='-1'>请选择</option>");
	        
	        for(var i=0;i<result.length;i++){
	          $("#ext3").append("<option value='"+result[i].id+"'>"+result[i].commodityName+"</option>");
	        }
	        

	        
            	

	        }
	    });  
}


$(function(){  
	  
}); 

  //奖品类型选择
  function awardTypeSel(){
	  var awardType = $("#awardType").val();
	  if(awardType==1){
		  $("#act").attr("hidden",false);
	  }else{
		  $("#act").attr("hidden",true);
		  $("#ext2 option:first").prop("selected", 'selected');
	  }

	  if(awardType==2){
		  $("#bus").attr("hidden",false);
	  }else{
		  $("#bus").attr("hidden",true);
		  $("#discountShop option:first").prop("selected", 'selected');
	  }
	  
  }
   
   //不发布
  function notRelease(){
	  location.href="${base}/awardstock/czjawardstockSaveExt1.do?awardstockId=${czjawardstock.awardstockId!}&ext1=0";
  }

  //发布
  function release(){
	  location.href="${base}/awardstock/czjawardstockSaveExt1.do?awardstockId=${czjawardstock.awardstockId!}&ext1=1";
  }

  //提交图片
  function submitVoteOrder(){
	  var awardType = $("#awardType").val();
	  var ext2 = $("#ext2").val();
	  var discountShop = $("#discountShop").val();
	  
	  var thingName = $("#thingName").val();
	  var countnum = $("#countnum").val();
	  var price = $("#price").val();
	  var content = $("#content").val();
	  var validDate = $("#validDate").val();
	  
	  var ext1 = $("#ext1").val();
	  
	  var ext3 = $("#ext3").val();
	  
     if(thingName==""){
		   alert("奖品名称不能为空！");
		   return;
     }	

	  if(countnum==""){
		   alert("库存数量不能为空！");
		   return;	    
}
             
     if(price==""){
		   alert("奖品价钱不能为空！");
		   return;
   }	      
     if(content==""){
		   alert("奖品描述不能为空！");
		   return;
   }	 
     if(validDate==""){
		   alert("奖品有效日期不能为空！");
		   return;
   }	      
     
     
	  
	  if(awardType==-1){
		   alert("奖品类型不能为空！");
		   return;
	  }
	  
	  if(awardType==1){
		   if(ext2==-1){
			   alert("优惠对应的活动不能为空！");
			   return;
		   } 
	  }

	  if(awardType==2){
		   if(discountShop==-1){
			   alert("优惠对应商家不能为空！");
			   return;
		   } 
	  }
	  
	  if(awardType==2){
		   if(discountShop!=-1){
			   if(ext3==-1){
				   alert("商品不能为空！");
				   return;
			   }
		   } 
	  }	  
	  
	 	        	
	         document.getElementById("myform").submit(); 
		  	  	  	  	  	  	 
  }
  
  
  function weather(){
	  
	    $.ajax({  
	        type : "get",  //提交方式  
	        url : "http://v.juhe.cn/weather/index",//路径  
	        async: false,
	        data : "cityname=%E5%B9%BF%E5%B7%9E&dtype=&format=&key=2c5e51150c7bca1d83ba8dc0e21b5209",//数据，这里使用的是Json格式进行传输      
	        dataType: "json",
	        success : function(result) {//返回数据根据结果进行相应的处理  
	        //var message =eval(result);
	        console.log(result);
	       console.log(result.msg);	
	        var result11 = result.result;
	        if(result11 == 0){
	        	alert("图片顺序不能重复");
	        	return false;
	        }else{
	        	
	         document.getElementById("myform").submit(); 
	        }
	       
	       
	        }
	    }); 
  }

  function isInteger(obj) {
	   return obj%1 === 0
	  }
	  isInteger(3) // true
	  isInteger(3.3) // false　 
  
  
	  $(function() {
		    //初始化
		        $('#validDate').datetimepicker(
						{
							language : 'zh-CN',//显示中文
							format : "yyyy-mm-dd",
							autoclose : true,
							todayBtn : true,
							startDate : "<#if (beginTime)??></#if>",
							minuteStep : 10,
							minView: "month"
						});
		});	  
	  
</script>



</body>
</html>